
#import <UIKit/UIKit.h>
#import "ServerCommunicationDelegate.h"
#import "NetworkRequest.h"

#define DATA_KEY @"key"
#define FILENAME_KEY @"file"
#define MIME_KEY @"mimetype"
#define BIANRY_DATA_KEY @"data"
#define FILE_PATH_KEY @"filepath"

#define INVALID_REQUEST_ID -1;

@interface BaseRequest : NSObject
{
    NSString*       _method;
    NSMutableDictionary*   _dataDict;
    NSMutableArray*        _binaryDataArray;
    NSMutableArray*        _fileDataArray;
    
    NSString*       _requestName;
    id<ServerCommunicationDelegate> _delegate;
    NSUInteger      _requestId;
    NetworkRequest* _request;
    id              _context;
    
    NSString*       _url;
    
}

@property (nonatomic,retain) NSString* method;
@property (nonatomic,retain) NSMutableDictionary* dataDict;
@property (nonatomic,retain) NSArray* binaryDataArray;
@property (nonatomic,retain) NSArray* fileDataArray;

@property (nonatomic,retain) NSString* requestName;
@property (nonatomic,retain) id<ServerCommunicationDelegate> delegate;
@property (nonatomic, assign) NSUInteger requestId;
@property (nonatomic,retain) NetworkRequest* request;
@property (nonatomic, retain) id context;
@property (nonatomic, retain) NSString* url;

@property (nonatomic,assign,readonly) int version;


//仅有dataDict时有效，其他情况自动转换为post. 默认使用httpGet
-(void)setRequestProtocolName:(NSString*)protocolname;
-(void)setRequestHttpGet;
-(void)setRequestHttpPost;
-(void)addStringValue:(NSString*)value forKey:(NSString*)key;
-(void)addDictionaryValue:(NSDictionary*)dict;
-(NSString*)getStringValueForKey:(NSString*)key;
-(void)addBinaryValue:(NSData*)value forKey:(NSString*)key withFileName:(NSString*)filename withMIMEtype:(NSString*)mimetype;
-(void)addFilePathValue:(NSString*)value forKey:(NSString*)key withFileName:(NSString*)filename withMIMEtype:(NSString*)mimetype;

-(void)printRequest;
@end
